package com.sgcc.operate.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.operate.domain.OPutChannel;
import com.sgcc.operate.service.IOPutChannelService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * 投放渠道Controller
 * 
 * @author sgcc
 * @date 2021-03-25
 */
@RestController
@RequestMapping("/putchannel")
public class OPutChannelController extends BaseController
{
    @Autowired
    private IOPutChannelService oPutChannelService;

    /**
     * 查询投放渠道列表
     */
//    //@PreAuthorize(hasPermi = "operate:putchannel:list")
    @GetMapping("/list")
    public TableDataInfo list(OPutChannel oPutChannel)
    {
        startPage();
        List<OPutChannel> list = oPutChannelService.selectOPutChannelList(oPutChannel);
        return getDataTable(list);
    }

    /**
     * 导出投放渠道列表
     */
    //@PreAuthorize(hasPermi = "operate:putchannel:export")
    @Log(title = "投放渠道", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OPutChannel oPutChannel) throws IOException
    {
        List<OPutChannel> list = oPutChannelService.selectOPutChannelList(oPutChannel);
        ExcelUtil<OPutChannel> util = new ExcelUtil<OPutChannel>(OPutChannel.class);
        util.exportExcel(response, list, "putchannel");
    }

    /**
     * 获取投放渠道详细信息
     */
//    //@PreAuthorize(hasPermi = "operate:putchannel:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(oPutChannelService.selectOPutChannelById(id));
    }

    /**
     * 新增投放渠道
     */
    //@PreAuthorize(hasPermi = "operate:putchannel:add")
    @Log(title = "投放渠道", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OPutChannel oPutChannel)
    {
        return toAjax(oPutChannelService.insertOPutChannel(oPutChannel));
    }

    /**
     * 修改投放渠道
     */
    //@PreAuthorize(hasPermi = "operate:putchannel:edit")
    @Log(title = "投放渠道", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OPutChannel oPutChannel)
    {
        return toAjax(oPutChannelService.updateOPutChannel(oPutChannel));
    }

    /**
     * 删除投放渠道
     */
    //@PreAuthorize(hasPermi = "operate:putchannel:remove")
    @Log(title = "投放渠道", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(oPutChannelService.deleteOPutChannelByIds(ids));
    }
}
